package com.knowledgegraph.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 实体类
 * 
 * @author system
 * @since 2024-01-01
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("kg_entity")
public class Entity implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 实体ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 实体名称
     */
    @NotBlank(message = "实体名称不能为空")
    @Size(max = 100, message = "实体名称长度不能超过100个字符")
    @TableField("name")
    private String name;

    /**
     * 实体类型
     */
    @TableField("type")
    private String type;

    /**
     * 实体描述
     */
    @TableField("description")
    private String description;

    /**
     * 实体属性JSON
     */
    @TableField("properties")
    private String properties;

    /**
     * 所属图谱ID
     */
    @TableField("graph_id")
    private Long graphId;

    /**
     * Neo4j节点ID
     */
    @TableField("neo4j_id")
    private Long neo4jId;

    /**
     * 标签
     */
    @TableField("labels")
    private String labels;

    /**
     * 创建者ID
     */
    @TableField("creator_id")
    private Long creatorId;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    /**
     * 逻辑删除
     */
    @TableLogic
    @TableField("deleted")
    private Integer deleted;

    /**
     * 关系数量（非数据库字段，用于查询结果）
     */
    @TableField(exist = false)
    private Integer relationCount;
}
